package com.kt.ktplayer.controller

import com.kt.ktplayer.model.TUserEntity
import com.kt.ktplayer.repository.TuserMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import java.lang.Exception
import java.util.HashMap

@RestController
class TuserController {

     @Autowired
     lateinit var tusermapper: TuserMapper

    @GetMapping("userlist")
    fun selectlist(): ResponseEntity<Map<String, Any>> {
        val responseEntity: ResponseEntity<Map<String, Any>>
        var resultmap = HashMap<String,Any>()
        try {
            var userlist:List<TUserEntity> = tusermapper.selectList(null);
            resultmap["data"]=userlist
            resultmap["message"]="成功"
            resultmap["status"]="SUCCESS"
        }
        catch (e: Exception){
            resultmap["message"]="失败"
            resultmap["status"]="FAIL"
        }
        finally {
            responseEntity = ResponseEntity(resultmap, HttpStatus.OK)
        }
        return responseEntity
    }
}